#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int minimumDeleteSum(string s1, string s2) {
        int n1 = s1.size(), n2 = s2.size(), len1 = 0, len2 = 0;
        for (auto c : s1) len1 += c;
        for (auto c : s2) len2 += c;
        s1 = ' ' + s1, s2 = ' ' + s2;
        vector<vector<int>> dp(n1 + 1, vector<int>(n2 + 1));
        for (int i = 1; i <= n1; i++)
            for (int j = 1; j <= n2; j++)
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                if (s1[i] == s2[j]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + s1[i]);
            }
        return len1 + len2 - dp[n1][n2] - dp[n1][n2];
    }
};